package service

import (
	"blog-service/internal/model"
	"errors"
)

type AuthRequest struct {
	AppKey    string `form:"app_key" binding:"required"`
	AppSecret string `form:"app_secret" binding:"required"`
}

func (svc *Service) CheckAuth(param *AuthRequest) error {
	authModel := model.Auth{AppKey: param.AppKey, AppSecret: param.AppSecret}
	auth, err := authModel.GetAuth()
	if err != nil {
		return err
	}

	if auth.ID > 0 {
		return nil
	}

	return errors.New("auth info does not exist.")
}
